package com.sbc.convention.result;

import com.sbc.convention.constants.CommonEnum;
import lombok.Data;
import lombok.experimental.Accessors;


import java.io.Serial;
import java.io.Serializable;

/**
 * @description: 全局返回对象
 * @author: songbaicheng
 * @create: 2024-02-26 18:11
 **/
@Data
@Accessors(chain = true)
public class Result<T> implements Serializable {

    @Serial
    private static final long serialVersionUID = 5679018624309023727L;

    /**
     * 返回码
     */
    private String code;

    /**
     * 返回消息
     */
    private String message;

    /**
     * 响应数据
     */
    private T data;

    /**
     * @return 是否成功
     */
    public boolean isSuccess() {
        return CommonEnum.SUCCESS.code().equals(code);
    }
}
